package com.liugui.reflect;

import java.io.File;
import java.io.FileDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

/**
 * @ClassName: ReflectDemo
 * @Author: liugui
 * @Date: 2020-11-09 11:12
 **/
public class ReflectDemo {
    public  int a;
    private int b;

    public static void main(String[] args) {
        Class<ReflectDemo> reflectDemoClass = ReflectDemo.class;

        for (Field declaredField : reflectDemoClass.getDeclaredFields()) {
            System.out.println("域：" + declaredField.getName() + " 修饰符：" + Modifier.toString(declaredField.getModifiers()));
        }
        //输出所有的公有域名称
        for (Field field : reflectDemoClass.getFields()) {
            System.out.println("公有域：" + field.getName() + " 修饰符：" + Modifier.toString(field.getModifiers()));
        }
        //输出类的所有方法名
        for (Method declaredMethod : reflectDemoClass.getDeclaredMethods()) {
            System.out.println("方法：" + declaredMethod.getName() + " 修饰符：" + Modifier.toString(declaredMethod.getModifiers()));
        }
    }

    public void fun1() {
    }

    private void fun2() {
    }
}


